@layout("/common/_curd/_container.html"){

<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";
	
	$(function(){
		initGrid();
		//initMenuBtn("btns", "${code}");
	});
	
	function initGrid(){
		var grid_url = ctx + "/${code}/co_organizer_list";
		var _colnames = ["ID", 
						"标题", 
						"状态", 
						"发起时间", 
						"发起人",
						"操作"];
		var _colmodel = [{name:"id", index:"id", width:100,hidden:true},
						{name:"title", index:"title", width:100},
						{name:"is_end", index:"is_end",formatter:fmatterStatus, width:100},
						{name:"ctime", index:"ctime", width:100},
						{name:"cname", index:"cname", width:100},
                        {name: 'id',formatter:fmatterOperation, width:200,sortable:false}
						];
		
		jQuery(grid_selector).jqGrid({
			url : grid_url,
		    shrinkToFit : true,
			colNames : _colnames,
			colModel : _colmodel, 
			jsonReader : {id :"id"},
			pager : pager_selector,
			postData : {sort : "id", order : "desc"}
		});
	}
    function fmatterOperation(cellvalue, options, rowObject){
        if (rowObject.stat==1){
            return '<button class="btn btn-primary btn-sm" onclick="view('+cellvalue+')">查看</button>';
        }else{
            return '<button class="btn btn-primary btn-sm" onclick="next('+cellvalue+')">处理</button>';
        }
    }
    function fmatterStatus(cellvalue, options, rowObject){
        if (cellvalue==1){
            return '<span class="label label-sm label-success">已完结</span>';
        }else{
            return '<span class="label label-sm label-warning">处理中</span>';
        }
    }
    function next(id){
    	var iframe_width=window.top.$(window).width();
    	var iframe_height=window.top.$(window).height();
        var index=layer.open({
            type: 2,
            title:"协同办公→处理",
            area: [iframe_width+"px",iframe_height+"px"],
            fix: false, //不固定
            maxmin: true,
            content: ctx + "/${code}/next/"+id
        });
    }
    function view(id){
    	var iframe_width=window.top.$(window).width();
    	var iframe_height=window.top.$(window).height();
        var index=layer.open({
            type: 2,
            title:"协同办公→查看",
            area: [iframe_width+"px",iframe_height+"px"],
            fix: false, //不固定
            maxmin: true,
            content: ctx + "/${code}/view/"+id
        });
    }
</script>

    <div class="row">
        <div class="col-xs-12">
            <div class="row-fluid" style="margin-bottom: 5px;">
                <div class="tabbable">
                    <ul class="nav nav-tabs padding-12 tab-color-blue background-blue" id="myTab4">
                        <li>
                            <a data-toggle="tab" href="#" onclick="javascript:window.location.href='${basePath}/${code}'" aria-expanded="false">我发起的流程</a>
                        </li>
                        <li  class="active">
                            <a data-toggle="tab" href="#" onclick="javascript:window.location.href='${basePath}/${code}/co_organizer'" aria-expanded="true">我协办的流程</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

	<!-- 配置 grid -->
	<div class="row">
		<div class="col-xs-12 tb-grid">
			<!-- 配置 查询 -->
			@ var _col=[
@		{name:"ID", index:"id", type:"text"},
			@		{name:"标题", index:"title", type:"text"},
			@		{name:"备注", index:"des", type:"text"},
			@		{name:"创建者", index:"cname", type:"text"},
			@		{name:"创建者ID", index:"cuser", type:"text"},
			@		{name:"创建时间", index:"ctime", type:"text"},
			@		{name:"0未结束1已结束", index:"is_end", type:"text"},
			@		{name:"当前处理人", index:"operator", type:"text"},
			@		{name:"当前处理人", index:"operator_id", type:"text"}							
			@];
			<!-- include("/common/_function/_search.html",{"col":_col}){} -->
			<!-- 按钮 
			<div class="welljq well-sm" id="btns"></div>-->
			<!-- grid -->
			<table id="grid-table"></table>
			<!-- 分页-->
			<div id="grid-pager"></div>
		</div>
	</div>
	
	<!-- 引入所需的js -->
	@include("/common/_listscript.html"){}
	
@}	